const getComponentList = require("./getComponentList")
const mock = require('mockjs')
const random = mock.Random



const getStatList = (len = 10) => {
  const res = []
  const compoentList = getComponentList()

  for (let i = 0; i < len; i++) {
    const stat = {
      _id: random.id(),
    }

    compoentList.forEach(c => {
      const { fe_id, type, props } = c
      switch (type) {
        case "questionInput":
          stat[fe_id] = random.ctitle()
          break
        case "questionTextarea":
          stat[fe_id] = random.ctitle()
          break
        case "questionRadio":
          stat[fe_id] = props.options[random.integer(0, 2)].label
          break
        case "questionCheckbox":
          stat[fe_id] = `${props.options[random.integer(0, 2)].label},${props.options[random.integer(0, 2)].label}`
          break
        case "questionInfo":
          stat[fe_id] = random.ctitle(10)
          break
      }
    })

    res.push(stat)
  }


  return res
}


module.exports = getStatList